package main

import (
	"fmt"
	"os"
)

func main() {
	//	获取当前目录
	fmt.Println(os.Getwd())
	//	cd 到指定目录
	os.Chdir("/tmp")
	//	新建, 需要路径下有权限
	fmt.Println(os.Getwd())

	//err := os.Mkdir("ostest", 0755)
	//if err != nil {
	//	fmt.Println("error occurred when creating new dir:", err)
	//	return
	//}
	// rename directory
	//os.Rename("ostest", "ostestnew")

	//	create a new file and insert contents
	os.Create("./file.txt")
	file, err := os.OpenFile("file.txt", os.O_RDWR|os.O_APPEND, 0666)
	file.WriteString("a test for os.append 2")
	fmt.Println(err)
}
